/**
 * @param {number[]} nums
 * @return {boolean}
 */
let canJump = function(nums) {
    let canJumpMaxIndex = 0;
    for (let i = 0; i < nums.length; i++) {
        if (i <= canJumpMaxIndex && i + nums[i] > canJumpMaxIndex)
            canJumpMaxIndex = i + nums[i];
    }
    return canJumpMaxIndex >= nums.length - 1;
};


console.log(canJump([3, 2, 1, 0, 4]));